<?php
$file = $_SERVER['DOCUMENT_ROOT'].'/core/database.xml';
//$file = realpath($file);

echo $file;



$xml = new DOMDocument("1.0", "UTF-8");
$xml->load($file);
//$xml->formatOutput = true;

$root = $xml->documentElement;

$xml_config = $xml->createElement('config', '');
$root->appendChild($xml_config);

$host = $xml->createElement('host');
$root->appendChild($host);
$host_content = $xml->createTextNode($_POST['host']);
$host->appendChild($host_content);

$login = $xml->createElement('login');
$root->appendChild($login);
$login_content = $xml->createTextNode($_POST['login']);
$login->appendChild($login_content);

$password = $xml->createElement('password');
$root->appendChild($password);
$password_content = $xml->createTextNode($_POST['password']);
$password->appendChild($password_content);

echo $xml->saveXML() .'<br />';

echo 'Wrote : '.$xml->save($file) .' bytes';
/*

try{
	$pdo = new PDO('mysql:host=localhost;dbname=test', 'root', 'root');
	$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
} catch(Exception $e) {
	die ('Erreur lors de la connexion '.$e->getMessage());
}
*/
